'''
@project:pythonProjectT174
@auther:zhongyingjie
@file:php.py
@date:2022/11/20 17:04
@desc:
'''
import re
import requests
from pytest_demo_T174.common.request_define import request_define
rd=request_define()
def php_dl():
    req_header={'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-CN,zh;q=0.9',
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.0.0 Safari/537.36'}
    home_url = 'http://47.107.178.45/phpwind/index.php?m=u&c=login'
    open_res = rd.create_request(req_type='GET', url=home_url,headers=req_header)
    csrf_token_zz='name="csrf_token" value="(.+?)"'
    csrf_token=rd.patter_find(csrf_token_zz,open_res)
    print(csrf_token)
    dl_url='http://47.107.178.45/phpwind/index.php?m=u&c=login&a=dologin'
    dl_data={'username':'c8513294n',
              'password':'cn19961011',
               'csrf_token':csrf_token,
               'csrf_token':csrf_token}
    dl_res=rd.create_request(req_type='POST',url=dl_url,data=dl_data,headers=req_header)
    # print(dl_res.text)
    statu_zz='_statu=(.+?)"'
    _statu=rd.patter_find(statu_zz,dl_res)
    # print(_statu)
    dlzt_url='http://47.107.178.45/phpwind/index.php?m=u&c=login&a=welcome&_statu=${statu}'
    cookies={'_ac_app_ua':'6fb8a3edb62dbbc09c',
'csrf_token':'csrf_token',
'zFb_visitor':'v1AfjVMro2eBHIvBSJhHLp0H03Z0Kpr9dvNth%2BJi74P0yxp3',
'zFb_lastvisit':'32%091668938691%09%2Fphpwind%2Findex.php%3Fm%3Du%26c%3Dlogin%26a%3Ddologin'}
    co_res=requests.get('http://47.107.178.45/phpwind/index.php?m=u&c=login&a=welcome&_statu=${statu}',cookies=cookies)
    dlzt_res=rd.create_request(req_type='GET',url=dlzt_url,headers=req_header)
    print(dlzt_res.text)
    ftan_url='http://47.107.178.45/phpwind/index.php?c=post&fid=10'
    ftan_res=rd.create_request(req_type='GET',url=ftan_url,headers=req_header)
    # print(ftan_res.text)
    ht_url='http://47.107.178.45/phpwind/index.php?c=post&a=doreply&_getHtml=1'
    ht_data={'csrf_token':csrf_token,
'atc_content':'估计会根据韩国123',
'tid':'31860'}
    ht_res=rd.create_request(req_type='POST',url=ht_url,data=ht_data)
    # print(ht_res.text)
    tc_url='http://47.107.178.45/phpwind/index.php?m=u&c=login&a=logout'
    tc_res=rd.create_request(req_type='GET',url=tc_url)
    # print(tc_res.text)
php_dl()

